#pragma once

#include "../DefinesCore.hpp"
#include "Node/Common.pb.h"
#include "Node/TaskRunnerPool.pb.h"
#include <string>
#include <map>
using namespace std;
CYBERTRON_BEGIN

class UtilStateHelper
{
public:
	UtilStateHelper();
	~UtilStateHelper();
	CybertronCoreAPI static UtilStateHelper& GetInstance() {
		static UtilStateHelper instance;
		return instance;
	}
	typedef map<string, Common::EWorkNodeType> WorkNodeName2TypeMap;
	typedef map<Common::EWorkNodeType, string> WorkType2NameMap;
	typedef map<Common::EWorkNodeType, string> WorkType2CommandLineMap;
	typedef map<Common::EWorkNodeType, string> WorkType2PathMap;
	typedef map<Common::EWorkNodeType, int> WorkType2DebugAttachMap;
	typedef vector<Common::EWorkNodeType> WorkTypeList;
	typedef map<Common::EWorkNodeType, WorkTypeList>  ScaleableNode2WorkTypeListMap;


	CybertronCoreAPI bool InitWorkListCfg(string baseDir, string moduleCfgPath);
	CybertronCoreAPI bool InitNameTypeMap(string content);
	CybertronCoreAPI bool InitScalableTypeMap(string content);

	CybertronCoreAPI string GetWorkNodeName(Common::EWorkNodeType workNodeType);
	CybertronCoreAPI Common::EWorkNodeType GetWorkNodeType(string workName);
	CybertronCoreAPI string GetWorkNodePath(Common::EWorkNodeType workNodeType);
	CybertronCoreAPI string GetWorkNodeCommandLine(Common::EWorkNodeType workNodeType);
	CybertronCoreAPI bool  GetScalableWorkNodeInfo(Common::EWorkNodeType workType,WorkTypeList& typeList);
	CybertronCoreAPI bool IsWorkNodeMayDebugAttach(Common::EWorkNodeType workNodeType);
	
	CybertronCoreAPI void SetWorkNodeCfg(Common::EWorkNodeType workNodeType,  string name, string path, string commandLine);


	
//typedef map<string , Common::EWorkNodeType>
public:
	CybertronCoreAPI static string getWorkNodeStatusName(Common::EWorkNodeStatus workNodeStatus);
	CybertronCoreAPI static string getWorkNodeStateName(Common::EWorkNodeState workNodeState);
	CybertronCoreAPI static string getTaskStateName(Common::ETaskState taskState);

	CybertronCoreAPI static string getWorkNodeTypeName(Common::EWorkNodeType workNodeType);
	CybertronCoreAPI static Common::EWorkNodeType getWorkNodeTypeName(string strType);
	CybertronCoreAPI static string getTaskRunnerPoolStateName(TaskRunnerPool::ETaskRunnerPoolState state);
protected:
	WorkNodeName2TypeMap mWorkNodeName2TypeMap;
	WorkType2NameMap mWorkType2NameMap;
	WorkType2CommandLineMap mWorkType2CommandLineMap;
	ScaleableNode2WorkTypeListMap mScaleableNode2WorkTypeListMap;
	WorkType2PathMap mWorkType2PathMap;
	WorkType2DebugAttachMap mWorkType2DebugAttachMap;
};

CYBERTRON_END
